home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / include / arggetter.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  2.6 KB  |  76 lines

  1.  
  2. #ifndef __arggetter_h__
  3. #define __arggetter_h__
  4.  
  5. #include "yacasbase.h"
  6.  
  7.  
  8. /**
  9.  LispArgGetter: a class that at construction gets the arguments, and
  10.  the function calling it just loops on until the end, getting arguments
  11.  by type.
  12.  */
  13.  
  14.  
  15. class LispArgGetter : public YacasBase
  16. {
  17. public:
  18.     inline LispArgGetter(LispEnvironment& aEnvironment, LispPtr& aArguments);
  19. public:
  20.     /// Get an argument that should be a (long) integer
  21.     LispStringPtr GetIntegerArgument(LispInt aEvaluate);
  22.     /// Get a string (atom)
  23.     LispStringPtr GetStringArgument(LispInt aEvaluate);
  24.     /// Get the atomic string of the argument
  25.     LispStringPtr GetAtomArgument(LispInt aEvaluate);
  26.     /// Get an argument that should be a short integer
  27.     LispInt GetShortIntegerArgument(LispInt aEvaluate);
  28.     /// Get a list argument
  29.     void GetListArgument(LispPtr& aResult, LispInt aEvaluate);
  30.     /// Get a void* pointer to a struct encapsulated in a generic class
  31.     void* GetVoidStruct(LispInt aEvaluate, LispCharPtr aTypeString);
  32.     /// Check that we are at the end of the list.
  33.     void Finalize(LispInt aNrArgsNeeded);
  34. private:
  35.     void GoNext();
  36. private:
  37.     LispEnvironment& iEnvironment;
  38.     LispPtr& iArguments;
  39.     LispIterator iIter;
  40.     LispInt iNrArgsParsed;
  41.     LispInt iNrArgsNeeded;
  42. };
  43.  
  44. inline LispArgGetter::LispArgGetter(LispEnvironment& aEnvironment, LispPtr& aArguments)
  45. : iEnvironment(aEnvironment),iArguments(aArguments), iIter(Argument(aArguments,0)),iNrArgsParsed(0)
  46. {}
  47.  
  48. #define ListArgument(_g,_list,_bool) LispPtr _list; (_g).GetListArgument(_list, _bool)
  49. #define IntegerArgument(_g,_i,_bool) LispStringPtr _i = (_g).GetIntegerArgument(_bool)
  50. #define ShortIntegerArgument(_g,_i,_bool) LispInt _i = (_g).GetShortIntegerArgument(_bool)
  51. #define InpStringArgument(_g,_i,_bool) LispCharPtr _i = (_g).GetStringArgument(_bool)->String()
  52.  
  53. #define DoubleFloatArgument(_g,_i,_bool) double _i = GetDoubleFloatArgument(_g,_bool)
  54. #define VoidStructArgument(_typ,_g,_i,_bool,_name) _typ _i = (_typ)(_g).GetVoidStruct(_bool,_name)
  55.  
  56.  
  57. void ReturnShortInteger(LispEnvironment& aEnvironment,
  58.                         LispPtr& aResult, LispInt r);
  59. void SetShortIntegerConstant(LispEnvironment& aEnvironment,
  60.                                     LispCharPtr aName,
  61.                                     LispInt aValue);
  62. double GetDoubleFloatArgument(LispArgGetter& g,LispInt aEvaluate);
  63. void ReturnDoubleFloat(LispEnvironment& aEnvironment,
  64.                        LispPtr& aResult, double r);
  65.  
  66.  
  67. void ReturnVoidStruct(LispEnvironment& aEnvironment,
  68.                       LispPtr& aResult,
  69.                       LispCharPtr aName,
  70.                       void* aData,
  71.                       void (*aFree)(void*));
  72.  
  73.  
  74. #endif
  75.  
  76.